package com.kaibes.platform.menu;

import javax.validation.constraints.Min;

import org.springframework.web.bind.annotation.PutMapping;

import com.kaibes.core.base.annotation.Description;

import lombok.Getter;
import lombok.Setter;

/**
CREATE TABLE `menu` (
  `id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(256) NOT NULL,
  `type` VARCHAR(32) NOT NULL,
  `icon` VARCHAR(32) NOT NULL DEFAULT '',
  `href` VARCHAR(32) NOT NULL DEFAULT '',
  `sort` TINYINT UNSIGNED NOT NULL DEFAULT '0',
  `parent_id` TINYINT UNSIGNED DEFAULT NULL,
  `enable` TINYINT NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `parent_id` (`parent_id`),
  FOREIGN KEY (`parent_id`) REFERENCES `menu` (`id`) ON DELETE SET NULL
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
 */
@Getter
@Setter
@Description("菜单结构")
public class Menu {
    
    @Description("菜单ID")
    @Min(value = 1, groups = PutMapping.class, message = "ID不能为空")
    private Short id;
    @Description("菜单名字")
    private String name;
    @Description("菜单类型")
    private String type;
    @Description("菜单图标")
    private String icon;
    @Description("菜单地址")
    private String href;
    @Description("菜单排序")
    private short sort;
    @Description("菜单开关")
    private Boolean enable;
    @Description("菜单父类")
    private Short parentId;
    
    @Override
    public String toString() {
        return href;
    }
    
}
